using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using EcsSiteDSTableAdapters;

namespace SiteECSWeb
{
    [DataObject]
    public class EmpQualificationBLL
    {
        private EmpQualificationTableAdapter _EmpQualificationAdapter = null;

        protected EmpQualificationTableAdapter EmpQualificationAdapter
        {
            get
            {
                if (_EmpQualificationAdapter == null)
                {
                    _EmpQualificationAdapter = new EmpQualificationTableAdapter();
                }
                return _EmpQualificationAdapter;
            }
        }

        #region SelectAuthorities
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public EcsSiteDS.EmpQualificationDataTable GetAllEmpQualification()
        {
            return EmpQualificationAdapter.GetEmpQualificationRowRankData();
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmpQualificationDataTable GetEmpQualificationByRowRank(int RowRank)
        {
            return EmpQualificationAdapter.GetEmpQualificationDataByRowRank(RowRank);
        }
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmpQualificationDataTable GetEmpQualificationByEmpQualfID(int EmpQualf_id)
        {
            return EmpQualificationAdapter.GetEmpQualificationDataByEmpQualfID(EmpQualf_id);
        }
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmpQualificationDataTable GetEmpQualificationByEcsEmpID(int Ecsemp_id)
        {
            return EmpQualificationAdapter.GetEmpQualificationDataByEcsEmpID(Ecsemp_id);
        }
       
        

        #endregion

        #region InsertAuthorities
        [DataObjectMethodAttribute(DataObjectMethodType.Insert,true)]
        public bool AddEmpQualification (string EmpQualf_Desc, DateTime? EmpQualf_Date, int Ecsemp_id)
        {
            EcsSiteDS.EmpQualificationDataTable EmpQualfTable = new EcsSiteDS.EmpQualificationDataTable();
            EcsSiteDS.EmpQualificationRow AddEmpQualfRow = EmpQualfTable.NewEmpQualificationRow();

            if (string.IsNullOrEmpty(EmpQualf_Desc)) AddEmpQualfRow.SetEmpQualf_DescNull(); else AddEmpQualfRow.EmpQualf_Desc = EmpQualf_Desc;
            if (EmpQualf_Date == null) AddEmpQualfRow.SetEmpQualf_DateNull(); else AddEmpQualfRow.EmpQualf_Date = EmpQualf_Date.Value;

            AddEmpQualfRow.Ecsemp_id = Ecsemp_id;
            
            EmpQualfTable.AddEmpQualificationRow(AddEmpQualfRow);

            int rowsAffected = EmpQualificationAdapter.Update(EmpQualfTable);
            return rowsAffected == 1; 
        }


        #endregion

        #region UpdateAuthorities
        [DataObjectMethodAttribute(DataObjectMethodType.Update, true)]
        public bool UpdateEmpQualification
            (string EmpQualf_Desc, DateTime? EmpQualf_Date, int Ecsemp_id, int EmpQualf_id)
        {
            EcsSiteDS.EmpQualificationDataTable EmpQualfTable =
                EmpQualificationAdapter.GetEmpQualificationDataByEmpQualfID(EmpQualf_id);
            if (EmpQualfTable.Count == 0)
            {
                return false;
            }

            EcsSiteDS.EmpQualificationRow EmpQualfRow = EmpQualfTable[0];

            if (string.IsNullOrEmpty(EmpQualf_Desc)) EmpQualfRow.SetEmpQualf_DescNull(); else EmpQualfRow.EmpQualf_Desc = EmpQualf_Desc;
            if (EmpQualf_Date == null) EmpQualfRow.SetEmpQualf_DateNull(); else EmpQualfRow.EmpQualf_Date = EmpQualf_Date.Value;

            EmpQualfRow.Ecsemp_id = Ecsemp_id;


            int rowsAffected = EmpQualificationAdapter.Update(EmpQualfRow);
            return rowsAffected == 1;
        }

        #endregion

        #region DeleteAuthorities
        [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
        public bool DeleteEmpQualification(int EmpQualf_id)
        {
            int rowsAffected = EmpQualificationAdapter.Delete(EmpQualf_id);
            return rowsAffected == 1;
        }
        #endregion


    }

}
